package com.manager.config.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manager.config.mapper.ProjectMapper;
import com.manager.config.service.ProjectService;


import com.manager.model.model.Project;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author pooh
* @description 针对表【project】的数据库操作Service实现
* @createDate 2023-03-19 12:45:43
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
    implements ProjectService {
    @Autowired
    ProjectMapper projectMapper;
    @Override
    public boolean addProject(String content) {
        Project project = projectMapper.searchByName(content);
        if(project == null){
            Project project1 = new Project();
            project1.setStatus(1);
            project1.setName(content);
            this.save(project1);
        }else{
            if(project.getStatus() == 0){
                project.setStatus(1);
                this.updateById(project);
            }else{
                return false;
            }
        }
        return true;
    }
}




